<template>
	<view class="container">
		<view class="left-bottom-sign"></view>
		<view class="back-btn yticon icon-zuojiantou-up" @click="navBack"></view>
		<view class="right-top-sign"></view>
		<!-- 设置白色背景防止软键盘把下部绝对定位元素顶上来盖住输入框等 -->
		<view class="wrapper">
			<view class="left-top-sign">Hypref Mall</view>
			<view class="welcome">欢迎回来 Hypref Mall 演示版 登录！</view>
			<view class="input-content">
			<button class="confirm-btn"  @click="taskLogin"  :disabled="logining">授权登录</button>
			</view>
		</view>
	</view>
</template>

<script>
	import {  
        mapMutations 
    } from 'vuex';
	
	export default{
		data(){
			return {
			}
		},
		onLoad(){},
		methods: {
			...mapMutations(['login']),
			navBack(){
				uni.navigateBack({
					delta:1
				});
			},
			taskLogin(){
				let that = this;
				uni.getUserProfile({
					provider: 'weixin',
					desc:'登录授权',
					success: (obj) => {
						uni.login({
						  provider: 'weixin',
						  success:  (loginRes) =>  {
							that.$api.postUrl(that.$api._api.ApiUserOpenId,{code:loginRes.code,avatarUrl:obj.userInfo.avatarUrl,nickName:obj.userInfo.nickName},function(res){
								that.$api.loading(false);
								that.login(res);
								var pages = getCurrentPages();
								if(pages.length > 1){
									uni.navigateBack({
										delta:1,
										animationType: 'pop-out',
										animationDuration: 200
									})
								} else{
									uni.reLaunch({
										url:"/pages/user/user"
									})
								}
							})
						  }
						});
					},
					fail: (re) => {
						console.log(re)
					}
				})
				
				that.$api.loading(true, "登陆中");
			}
		},
	}
</script>
<style lang='scss'>
	page{
		background: #fff;
	}
	.container{
		padding-top: 115px;
		position:relative;
		width: 100vw;
		height: 100vh;
		overflow: hidden;
		background: #fff;
	}
	.wrapper{
		position:relative;
		z-index: 90;
		background: #fff;
		padding-bottom: 40rpx;
	}
	.back-btn{
		position:absolute;
		left: 40rpx;
		z-index: 9999;
		padding-top: var(--status-bar-height);
		top: 40rpx;
		font-size: 40rpx;
		color: $font-color-dark;
	}
	.left-top-sign{
		font-size: 120rpx;
		color: $page-color-base;
		position:relative;
		left: -16rpx;
	}
	.right-top-sign{
		position:absolute;
		top: 80rpx;
		right: -30rpx;
		z-index: 95;
		&:before, &:after{
			display:block;
			content:"";
			width: 400rpx;
			height: 80rpx;
			background: #b4f3e2;
		}
		&:before{
			transform: rotate(50deg);
			border-radius: 0 50px 0 0;
		}
		&:after{
			position: absolute;
			right: -198rpx;
			top: 0;
			transform: rotate(-50deg);
			border-radius: 50px 0 0 0;
			/* background: pink; */
		}
	}
	.left-bottom-sign{
		position:absolute;
		left: -270rpx;
		bottom: -320rpx;
		border: 100rpx solid #d0d1fd;
		border-radius: 50%;
		padding: 180rpx;
	}
	.welcome{
		position:relative;
		left: 50rpx;
		top: -90rpx;
		font-size: 46rpx;
		color: #555;
		text-shadow: 1px 0px 1px rgba(0,0,0,.3);
	}
	.input-content{
		padding: 0 60rpx;
	}
	.input-item{
		display:flex;
		flex-direction: column;
		align-items:flex-start;
		justify-content: center;
		padding: 0 30rpx;
		background:$page-color-light;
		height: 120rpx;
		border-radius: 4px;
		margin-bottom: 50rpx;
		&:last-child{
			margin-bottom: 0;
		}
		.tit{
			height: 50rpx;
			line-height: 56rpx;
			font-size: $font-sm+2rpx;
			color: $font-color-base;
		}
		input{
			height: 60rpx;
			font-size: $font-base + 2rpx;
			color: $font-color-dark;
			width: 100%;
		}	
	}

	.confirm-btn{
		width: 630rpx;
		height: 76rpx;
		line-height: 76rpx;
		border-radius: 50px;
		margin-top: 70rpx;
		background: $uni-color-primary;
		color: #fff;
		font-size: $font-lg;
		&:after{
			border-radius: 100px;
		}
	}
	.forget-section{
		font-size:28rpx;
		color: $font-color-spec;
		text-align: center;
		margin-top: 40rpx;
	}
	.register-section{
		position:absolute;
		left: 0;
		bottom: 50rpx;
		width: 100%;
		font-size:28rpx;
		color: $font-color-base;
		text-align: center;
		text{
			color: $font-color-spec;
			margin-left: 10rpx;
		}
	}
	.input-item-sms-code {
	  position: relative;
			width: 100%;
	  .sms-code-btn {
	    position: absolute;
	    color: #111;
	    right: 20rpx;
	    bottom: 20rpx;
	    font-size: 28rpx;
	  }
	
	  .sms-code-resend {
	    color: #999;
	  }
	
	  .sms-code-btn:after {
	    border: none;
	    background-color: transparent;
	  }
	}
</style>
